package com.example.nonacademic_education.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.stp.StpUtil;
import com.example.nonacademic_education.constant.Constant;
import com.example.nonacademic_education.util.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {
    @GetMapping("isLogin")
    @SaIgnore
    public R isLogin(){
        boolean isLogin;
        try {
            isLogin=StpUtil.isLogin();
            if (isLogin){
                return R.ok("isLogin");
            }else {
                return new R(Constant.TOKEN_ERROR_CODE,null,"");
            }
        }catch (Exception e){
            return R.error("认证错误："+e.getClass().getName());
        }
    }
}
